/*
 *  $Id: TargetArgs.cs 1233 2010-12-18 17:54:48Z thenn.erannor $
 *  This file is a part of Ragima CCG.
 *  (C) 2008-2010 Ragima development group.
 *
 *  Licensed under the terms of the GNU GPL License version 2.
 *
 */

using System;
using System.Collections.Generic;
using System.Reflection;

using Nereal.Extensions;
using Nereal.Serialization;

namespace Ragima {
    /// <summary>
    /// Базовый класс для параметров цели.
    /// </summary>
    [XmlRootName("args"), TypeResolver(typeof(AttrTypeResolver<TargetArgs>), "id")]
    public class TargetArgs {
        [XmlName("player"), Reference(true, typeof(bool), Serialization.Resolvers.GamePlayer)]
        public Player Player;

        [XmlName("caster"), Reference(true, typeof(string), Serialization.Resolvers.GameObject)]
        public AbstractObject Caster;

        public TargetArgs() {
        }
        public TargetArgs(Player player, AbstractObject caster) {
            Player = player;
            Caster = caster;
        }

        public IEnumerable<Player> Players {
            get {
                yield return Player;
                yield return Player.Enemy;
            }
        }
    }

    /// <summary>
    /// Абстракные параметры цели с конкретной целью указанного типа.
    /// </summary>
    public abstract class TargetArgs<T> : TargetArgs {
        [NotSerialize]
        public abstract T Target { get; }

        public TargetArgs() {
        }
        public TargetArgs(Player player, AbstractObject caster) : base(player, caster) {
        }
    }
}
